﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script>

        var myApp = (function () {

            var id = 0;

            return {
                next: function () {
                    return id++;
                },

                reset: function () {
                    id = 0;
                },

                nested: (function () {
                    return {
                        doSomething: function () {
                            alert('iah');
                        }
                    }
                })()
            };
        })();

        window.console && console.log(
	myApp.next(),
	myApp.next(),
	myApp.reset(),
	myApp.next()
);  //0, 1, undefined, 0
        myApp.nested.doSomething();
    </script>
</head>
<body>

</body>
</html>
